<template>
  <el-tabs :tab-position="tabPosition" :type="type" @tab-click="handleClick">
    <el-tab-pane v-for="(tab, index) in tabList" :key="index">
      <template #label>
        <div class="app-icon">
          
            <img :src="require(`@/assets/img/Taxonomy/${tab.icon}.png`)" alt />
            <span > {{ tab.name }}</span>
        </div>
      </template>
      <div ref="icon-content" class="icon-content">
        <SideEntrance :appList="tab.app" />
      </div>
    </el-tab-pane>
  </el-tabs>
</template>
<script>
import login from "@/mixin/login";
import SideEntrance from "./SideEntrance";
import { reactive, toRef, toRefs, getCurrentInstance, onMounted } from "vue";

function useFeatureX() {
  // 响应式数据抽离出setup 具有代码可读性
  const state = reactive({});
  return state;
}

export default {
  name: "Tabs",
  components: { SideEntrance },
  props: {
    type: {
      type: String,
      default: "",
    },
    tabPosition: {
      type: String,
      default: "",
    },
    tabList: {
      type: Array,
      default: [],
    },
  },
  // context
  setup(props, { attrs, slots, emit }) {
    let data = useFeatureX();
    const { ctx } = getCurrentInstance();
    const handleClick = (tab, event) => {
      // console.log(tab, event);
    };
    onMounted(() => {});
    return {
      ...toRefs(data),
      handleClick,
    };
  },
};
</script>


<style lang="scss">
.el-tabs.el-tabs--border-card {
  border: none;
}
.el-tabs {
  width: 100vw;
  height: 100vh;

  .el-tabs__item.is-left {
    width: 10vw;
    min-width: 55px;
    max-width: 200px;
    padding: 0 10px;
    font-size: 1.1rem;
    font-weight: 700;
    height: 75px;
    line-height: 75px;
    .app-icon {
      width: 30px;
      font-size: 18px;
      font-weight: 700;
      img {
        width: 100%;
        margin-right: 20px;
        vertical-align: middle;
      }
    }
  }
  .icon-content {
    height: 100vh;
    overflow-y: auto;
    min-width: 350px;
  }
}
</style>